﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace _15.列表控件 {
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window {
        public MainWindow() {
            InitializeComponent();
        }

        private void fst_SelectionChanged(object sender, SelectionChangedEventArgs e) {
            if (fst.SelectedItem == null)
                return;
            this.tstSelection.Text = $"You Choose Item at Position {fst.SelectedItem}\r\n Checked state is {((CheckBox) this.fst.SelectedItem).IsChecked}";
        }

        private void Button_Click(object sender, RoutedEventArgs e) {
            var sb = new StringBuilder();
            foreach(CheckBox item in fst.Items) {
                if (item.IsChecked == true) {
                    sb.Append(item.Content);
                    sb.Append(" is checked");
                    sb.Append('\n');
                }
                tstSelection.Text = sb.ToString();
            }
        }
    }
}
